<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>

	<script src="./lib/template-web.js"></script>
</head>

<body style="padding: 15px;">




	<script>
		/* 
		1、创建实例对象
		2、调用open   设置请求类型+url
		3、调用send   发送请求
		4、监听[readyState]是否请求完成   onreadystatechange
		5、判断请求是否完成   readyState
		 */
		 //var id=11;
		const xhr = new XMLHttpRequest()
		//console.log(xhr.readyState, 8888);
		xhr.open('get', 'http://www.liulongbin.top:3006/api/getbooks')
		//console.log(xhr.readyState, 8888);
		xhr.send()
		//console.log(xhr.readyState, 8888);
		xhr.onreadystatechange = function() {
			//console.log(xhr.readyState, 8888);

			// 	if (xhr.readyState == 4 && xhr.status == 200) {
			// 		//  判断是否请求完成  以及是否状态200  成功
			console.log( xhr.response);
			// 		//console.log(typeof xhr.response);

			// 	}
		}
	</script>

</body>

</html>
